Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable validation and code completion for XML documents without schemaLocation #6245

Merged
merged 4 commits into from
Aug 12, 2023

Conversation

matthiasblaesing
Copy link
Contributor

NetBeans allows users to register DTDs and XSD to support code completion and validation for XML files referencing them.

For DTDs it is possible to register them either by their public ID or their system ID. For XSD only the registration based on system ID was used. This in turn requires the document to be validated to carry a xsi:schemaLocation and/or xsi:noNamespaceSchemaLocation attribute to link the XSD to the XML.

That makes sense where the namespace itself is not an identifier. For example Jakarta EE 9 used one big namespace: https://xmlns.jakarta.ee/jakartaee, but multiple grammars (e.g. https://jakarta.ee/xml/ns/jakartaee/jakartaee_9.xsd and https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd). On the other hand there can be approaches where the namespace identifies the grammer uniquely. For these cases validation and code completion was enhanced to allow for this.

In #6226 an example was provided, that looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<rde:deposit xmlns:rde="urn:ietf:params:xml:ns:rde-1.0"
             xmlns:rdeHost="urn:ietf:params:xml:ns:rdeHost-1.0"
             xmlns:rdeEppParams="urn:ietf:params:xml:ns:rdeEppParams-1.0"
             xmlns:epp="urn:ietf:params:xml:ns:epp-1.0"
             xmlns:ns5="urn:ietf:params:xml:ns:rdeCsv-1.0"
             xmlns:rdeHeader="urn:ietf:params:xml:ns:rdeHeader-1.0"
             xmlns:rdeNNDN="urn:ietf:params:xml:ns:rdeNNDN-1.0"
             xmlns:rdeIDN="urn:ietf:params:xml:ns:rdeIDN-1.0"
             xmlns:rdeRegistrar="urn:ietf:params:xml:ns:rdeRegistrar-1.0"
             xmlns:rdeDomain="urn:ietf:params:xml:ns:rdeDomain-1.0"
             xmlns:domain="urn:ietf:params:xml:ns:domain-1.0"
             xmlns:secDNS="urn:ietf:params:xml:ns:secDNS-1.1"
             xmlns:rdeContact="urn:ietf:params:xml:ns:rdeContact-1.0"
             xmlns:contact="urn:ietf:params:xml:ns:contact-1.0"
             type="FULL"
             id="F202006291123"
             resend="0">
    <rde:watermark>2020-06-29T00:00:00.000Z</rde:watermark>
    <rde:rdeMenu>
        <rde:version>1.0</rde:version>
        <rde:objURI>urn:ietf:params:xml:ns:rdeHeader-1.0</rde:objURI>
        <rde:objURI>urn:ietf:params:xml:ns:rdeContact-1.0</rde:objURI>
        <rde:objURI>urn:ietf:params:xml:ns:rdeHost-1.0</rde:objURI>

each namespace uniquely identifies the grammar that defines it. There is no schemaLocation attribute, so the schemas need to be mapped:

image

image

Then XML validation works:

image

And the editor can provide schema based completion:

image

@matthiasblaesing matthiasblaesing added enhancement Code cleanup DO NOT squash UI User Interface tests ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Jul 21, 2023
@matthiasblaesing matthiasblaesing added this to the NB20 milestone Jul 21, 2023
@matthiasblaesing matthiasblaesing linked an issue Jul 22, 2023 that may be closed by this pull request
@matthiasblaesing
Copy link
Contributor Author

If noone objects, I'll merge this by the end of the week.

@matthiasblaesing matthiasblaesing merged commit 256f1b3 into apache:master Aug 12, 2023
@matthiasblaesing matthiasblaesing deleted the xml_validation branch August 12, 2023 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Code cleanup DO NOT squash enhancement tests UI User Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XML validation breaks with multiple schema files
1 participant